Plot
A Swiss knife for displaying 2D data
Plot[expr_, {variable, min, max, step}, opts__]
has HoldFirst
attribute. See the list of supported options (opts
) down below
Optionsβ
PlotStyle
β
Works as in Mathematica, i.e. per element in expr
array, supports color, opacity and etc
Plot[Table[x^y, {y, 6}]//Evaluate, {x, 0,1}, PlotStyle->Table[Blend[{Red, Blue}, i/6], {i, 6}]]
AxesLabel
β
Place labels on your axes
Plot[Sinc[x], {x, 0, 10}, AxesLabel -> {"x", "Sinc[x]"}]
Labels accepts only strings or numbers unlike Mathematica, where you can put everything.
Since it is translated into Text
, one can use sort of TeX math input
Plot[PDF[NormalDistribution[0, 1], x], {x, -10, 10}, AxesLabel -> {"wavenumber (cm^{-1})", "absorption \\alpha"}, PlotRange->Full]
It also supports absolute positioning using offset
Plot[PDF[NormalDistribution[0, 1], x], {x, -10, 10}, AxesLabel -> {"wavenumber (cm^{-1})", {"absorption \\alpha", {112,0}}}, PlotRange->Full]
Ticks
β
Customize ticks by providing an array of numbers for both axes
Plot[x, {x, 0, 1}, Ticks->{{0, 0.5, 1}, {}}]
Or by providing as pairs {Number, String}
one can specify the displayed text
Plot[x, {x, 0, 1}, Ticks->{{{0, "Zero"}, {0.5, "Half"}, {1,"One"}}, {}}]
Controls
πβ
This is more an option for Graphics, but with a bit of a hacking it can be used here as well. The features allows to pan and zoom your plots, that was never possible in Mathematica
Plot[Sin[1/x], {x, 0.001, 0.1}, MaxRecursion->1];
Insert[%, Controls->True, {2,-1}]
Try to use your mouse here
Frame
β
Turns plot into the journals-like styled graph. In general it has much more options to customize the look
Plot[x, {x, 0, 1}, Frame->True]
FrameTicks
β
The same as Ticks
, but for this regime.
FrameLabel
β
The same as AxesLabel
Plot[x, {x, 0, 1}, Frame->True, FrameLabel->{
"x-axis",
"y-axis"
}]
one can specify an absolute offset for a label by wrapping it into a list
Plot[x, {x, 0, 1}, Frame->True, FrameLabel->{
"x-axis",
{"y-axis", {0,50}}
}]
FrameStyle
β
Affects the style of FrameLabels
. Use Directive
for changing the style
Plot[x, {x, 0, 1}, Frame->True, FrameLabel->{"x-axis", "y-axis"}, FrameStyle->Directive[FontSize->16]]
FrameTicksStyle
β
Affects the style of FrameTicks
Plot[x, {x, 0, 1}, Frame->True, FrameLabel->{"x-axis", "y-axis"}, FrameTicksStyle->Directive[FontSize->16]]
TickLabels
β
Since Plot
options are hardcoded in WL core, we cannot add new options, however using trick with Insert
any values can be provided to the resulting Graphics
expression
To remove unnecessary ticks, use
Plot[x, {x, 0, 1}, Frame->True];
Insert[%, "TickLabels"->{{True, False}, {True, False}}, {2,-1}]
ClippingStyle
β
Show the clipped regions like the rest of the curve and colored
Plot[Sin[x]/x^2, {x, -10, 10}, ClippingStyle -> Red]
Filling
β
Fill the area under, over of between curves
Plot[Evaluate[Table[BesselJ[n, x], {n, 4}]], {x, 0, 10}, Filling -> Axis]
Possible options will be
Bottom
Top
{1 -> {2}}
from curve 1 to 2
Baseline
β
Align graphs by theΒ Β axis in each plot:
{Plot[Im[Zeta[1/2 + I t]], {t, -20, 20}, BaselinePosition -> Axis],
Plot[Re[Zeta[1/2 + I t]], {t, -20, 20}, BaselinePosition -> Axis]} // Row
Epilog
β
Puts any graphics object on top of the data plotted
Plot[Sin[x], {x, 0, 2 Pi}, Epilog -> {PointSize[0.04], Point[{0, 0}], Point[{Pi, 0}], Point[{2 Pi, 0}]}]
It opens up many possibilities, since it provides low-level access to the Graphics
canvas.
Prolog
β
The same as Epilog
, but acts before plotting the data.
ExclusionsStyle
β
Use red lines to indicate the vertical asymptotes
Plot[Tan[x], {x, 0, 10}, Exclusions -> {Cos[x] == 0},
ExclusionsStyle -> Red]
ImageSize
β
A common option for any graphics
ImageSize -> Width
or
ImageSize -> {Width, Height}
It uses pixels as units
MaxReqursion
β
Affects the accuracy of the plot when it comes to the sudden changes of a sampled function
Plot[Sin[1/x], {x, 0.001, 0.1}, MaxRecursion->1]
The lowest values is 0
Mesh
β
Shows sampling points
Plot[Sin[1/x], {x, 0.001, 0.1}, Mesh -> All]
PeformanceGoal
β
Affects the number of sampling points to reduce the load
"Speed"
"Quality"
PlotPoints
β
Change the initial sampling points
- a number
PlotLegends
β
Is quite limited. Accepts Automatic
, "Expressions"
or List
of expressions to show
PlotRange
β
Change the lot range to show the whole area
Plot[Sqrt[x], {x, -5, 5}, PlotRange -> Full]
Or a custom range
Plot[Sqrt[x], {x, -5, 5}, PlotRange -> {{-5,5}, {0,1}}]
RegionFunction
β
Show the specific area only
Plot[Sin[x], {x, 0, 8 Pi}, RegionFunction -> Function[{x, y}, Abs[y] > 0.5]]
Axes
β
Currently is not supported by Graphics ;(
Show or hide axes of the plot
Plot[Sinc[x], {x, 0, 10}, Axes -> False]
Dynamicsβ
Consider to use ManipulatePlot for manipulating parameters of a function in real time